<?php
namespace Common\Model;
use Think\Model;

/**
 * 优惠券
 * Class DiscountCouponModel
 * @package Common\Model
 */
class DiscountCouponModel extends Model  {

    protected $tableName = 'b2c_discount_coupon';
    public $local_id;

    public function __construct()
    {
        parent::__construct();
        $this->local_id = session('userInfo')['local_id'];
    }

    /**
     * 获取未过期的优惠券
     * @return mixed
     */
    public function getDiscountCoupon(){
        $time = date('Y-m-d H:i:s', time());
        $where['end_time'] = ['EGT', $time];
        $where['local_id'] = $this->local_id;
        $discount_coupon_msg = $this->where($where)->order('sort asc')->select();
        return $discount_coupon_msg;
    }


}